<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>角色主页</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<%@ include file="/WEB-INF/common.jsp"%>

<link href="${path }/resources/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="${path }/resources/css/animate.css" rel="stylesheet">
<link href="${path }/resources/css/style.css?v=4.1.0" rel="stylesheet">

<!--dataTables css样式-->
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/jquery.dataTables.min.css">
<!--DataTables button扩展-->
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/buttons.dataTables.min.css">
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/form.css">

<style>

label.error { display: none; }
</style>
</head>
<body class="gray-bg" style="">
<jsp:include page="/WEB-INF/loginCheck.jsp" />
	<div>
		<h1 style="margin-left:20px">添加人员账号</h1>
	</div>
	<hr>
	<!--添加的表单  -->
	<div id="" barclass="panel-body" style="margin-top: 30px">
		<%-- action="${path }/Enterprise/addEnterPerson.htm" method="post"  --%>
		<form id="cForm" data-parsley-validate class="form-horizontal form-label-left" >
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">员工姓名：<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  value="" name="name" class="form-control col-md-7 col-xs-12" >
				</div>
			</div>
			<div class="form-group">
				
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="first-name">性别<span class="required">*</span>
				</label>
				<label style="font-size:20px"><input value="男" name="gender" type="radio" style="margin-left:80px;">男</label>
				<label style="font-size:20px"><input value="女" name="gender" type="radio"  style="margin-left:200px;">女</label>
				<label for="gender" class="error">请选择性别</label>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">年龄<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  value="" name="age" class="form-control col-md-7 col-xs-12"  >
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">电话<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  value="" name="phone_number" class="form-control col-md-7 col-xs-12" >
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">身份证号<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  value="" name=identification_card  class="form-control col-md-7 col-xs-12" >
				</div>
			</div>
<!-- 			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">密码<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  value="" name="password" class="form-control col-md-7 col-xs-12" >
				</div>
			</div> -->
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">身份<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<select id="identity" class="selectpicker form-control" data-live-search="true" name="personIdentity">
						<option value="维保企业">维保企业</option>
					</select>
					<label for="identity" class="error">请选择身份</label><br>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">所属维保企业<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<select id="enterprise_id" class="selectpicker form-control" data-live-search="true" name="enterprise_id">
					    <c:forEach items="${enterList}" var="enterList" >
							<option value="${enterList.id}"><c:out value="${enterList.name}"/></option>
						</c:forEach>
					</select>
				<label for="enterprise_id" class="error">请选择所属维保企业</label><br>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">角色<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<select id="roleId" class="selectpicker form-control" data-live-search="true" name="roleId" >
						<option value="3">维保工程师</option>
		                <option value="2">项目负责人</option>
		                <option value="1">企业管理员</option>
					</select>
				<label for="roleId" class="error">请选择角色</label><br>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">专业技术等级<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<select id="technical_level" class="selectpicker form-control" data-live-search="true" name="technical_level">
						<option value="一级">一级</option>
		                <option value="二级">二级</option>
		                <option value="三级">三级</option>
					</select>
				<label for="technical_level" class="error">请选择专业技术等级</label><br>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">职务<span class="required">*</span>
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input  value="" name="position" class="form-control col-md-7 col-xs-12" >
				</div>
			</div>
			<div class="form-group">				
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="first-name">状态<span class="required">*</span>
				</label>
				<lable style="font-size:20px"><input value="开启" name="status" type="radio"  style="margin-left:80px;">开启</lable>
				<lable style="font-size:20px" ><input value="停止" name="status" type="radio"  style="margin-left:200px;">停止</lable>
				<label for="status" class="error">请选择状态</label>
			</div>
			<div class="form-group">
				<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3" >
					<button type="submit" class="btn btn-success">提交</button>
					<a href="${path }/Enterprise/getPersonList.htm" class="btn btn-primary" style="margin-left:500px;">返回</a>
				</div>
			</div>

		</form>

	</div>
	
  	<!--表格  -->
 	<div class="col-md-12 col-sm-12 col-xs-12" style="margin-top: 30px">
	

	</div>
 
 

		

	
	

	
	

	
	<!-- Peity-->
	<script src="${path }/resources/js/plugins/peity/jquery.peity.min.js"></script>
	
	<!-- Bootstrap table-->
	<script src="${path }/resources/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="${path }/resources/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

	<!-- 自定义js-->
	<script src="${path }/resources/js/content.js?v=1.0.0"></script>
	
	<!-- jQuery Validation plugin javascript-->
    <script src="${path }/resources/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${path }/resources/js/plugins/validate/messages_zh.min.js"></script>
   
   	<!-- jQuery form  -->
    <script src="${path }/resources/js/jquery.form.min.js"></script>
    
    <!-- layer javascript -->
    <script src="${path }/resources/js/plugins/layer/layer.min.js"></script>
     <!-- 表单验证 -->
    <script src="${path }/resources/js/jquery.min.js"></script>
    <script src="${path }/resources/js/jquery.validate.min.js"></script>
    
 
	<script type="text/javascript">
	$("#cForm").validate({
		onsubmit:true,// 是否在提交是验证
		onfocusout:false,// 是否在获取焦点时验证
		onkeyupd :false,// 是否在敲击键盘时验证
		
		rules:{
			name:{
				required:true
			},
			gender:{
				required:true
			},
			age:{
				required:true,
				digits:true//必须输入整数
			},
			phone_number:{
				required:true,
			 	digits:true,
			 	rangelength:[11,11],//输入长度
			},
			identification_card:{
				required:true,
				digits:true
			},
			password:{
				required:true
			},
			personIdentity:{
				required:true
			},
			position:{
				required:true
			},
			status:{
				required:true
			},
		},
		messages:{
			name:{
				required:"请输入用户名"
			},
			gender:{
				required:"请选择性别"
			},
			age:{
				required:"请输入年龄",
				digits:"年龄必须是整数"
			},
			phone_number:{
				required:"请输入电话",
				digits:"年龄必须是整数",
				rangelength:"电话号码必须是11位"
			},
			identification_card:{
				required:"请输入身份证号",
				digits:"身份证号必须是整数"
			},
			password:{
				required:"请输入密码"
			},
			personIdentity:{
				required:"请选择身份"
			},
			position:{
				required:"请输入职务"
			},		
			status:{
				required:"请选择状态"
			},
		},
		submitHandler:function(form){//通过之后回调
			var name = $("input[name='name']").val(); 
			var gender = $("input[name='gender']:checked").val(); 
			var age = $("input[name='age']").val();
			var phone_number = $("input[name='age']").val();
			var password = $("input[name='password']").val();
			var identity=document.getElementById("identity").value;
			var enterprise_id=document.getElementById("enterprise_id").value;
			var roleId=document.getElementById("roleId").value;
			var identification_card = $("input[name='identification_card']").val(); 
			var position = $("input[name='position']").val(); 
			var technical_level=document.getElementById("technical_level").value;
			var status=$("input[name='status']:checked").val();
			$.ajax({
				url:"/firefighting/Enterprise/addEnterPerson.htm",
				type:'POST',
				dataType:'json',
	 			data:{
					name:name,
					gender:gender,
					age:age,
					phone_number:phone_number,
					password:password,
					identity:identity,
					enterprise_id:enterprise_id,
					roleId:roleId,
					identification_card:identification_card,
					position:position,
					technical_level:technical_level,
					status:status,
					type:2
				},   
				success:function(data)
				{
					alert("请牢记您的登陆账号："+data.userName+"  初始密码为：123456");
					window.location.href="/firefighting/Enterprise/getPersonList.htm";
				},
				
		        error:function(data)
		        {
		        	$("#example").html("");
		        	$.unblockUI();
		        	$(".tbody"). empty();
		        }
			});
		}
		
	});
/* 	$("#submit").click(function(){		
		var name = $("input[name='name']").val(); 
		var gender = $("input[name='gender']:checked").val(); 
		var age = $("input[name='age']").val();
		var phone_number = $("input[name='age']").val();
		var password = $("input[name='password']").val();
		var identity=document.getElementById("identity").value;
		var enterprise_id=document.getElementById("enterprise_id").value;
		var roleId=document.getElementById("roleId").value;
		var identification_card = $("input[name='identification_card']").val(); 
		var position = $("input[name='position']").val(); 
		var technical_level=document.getElementById("technical_level").value;
		var status=$("input[name='status']:checked").val(); 
		$.ajax({
			url:"/firefighting/Enterprise/addEnterPerson.htm",
			type:'POST',
			dataType:'json',
 			data:{
				name:name,
				gender:gender,
				age:age,
				phone_number:phone_number,
				password:password,
				identity:identity,
				enterprise_id:enterprise_id,
				roleId:roleId,
				identification_card:identification_card,
				position:position,
				technical_level:technical_level,
				status:status,
				type:2
			},   
			success:function(data)
			{
				alert("请牢记您的登陆账号："+data.userName);
				window.location.href="/firefighting/Enterprise/getPersonList.htm";
			},
			
	        error:function(data)
	        {
	        	$("#example").html("");
	        	$.unblockUI();
	        	$(".tbody"). empty();
	        }
		});
		 
	});	 */
	</script>

</body>
</html>